﻿/*
/*NHibernate映射代码模板
/*吕震修改使用升级版My Generation映射 Oracle
*/
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;

using Model.Common;


namespace Model
{
	/// <summary>
	///	Competence:权限
	/// </summary>
	[Serializable]
	public partial class Competence : IDataEntity 
	{
		#region 私有成员
			
		private bool keyIsChanged;
		private bool keyIsDeleted;
		private int keyCompetenceId; 
		private int keyRoleId; 
		private string keyCompetenceName; 
		private string keyCompetenceCode; 
		private string keyCompetenceDescription; 
		private int keyVersion; 		
		
		#endregion
		
		#region 默认( 空 ) 构造函数
		/// <summary>
		/// 默认构造函数
		/// </summary>
		public Competence()
		{
			keyCompetenceId = 0; 
			keyRoleId = 0; 
			keyCompetenceName = null; 
			keyCompetenceCode = null; 
			keyCompetenceDescription = null; 
			keyVersion = 0; 
		}
		#endregion
		
		#region  公有属性
			
		
		/// <summary>
		/// CompetenceId:主键id
		/// </summary>		
		public virtual int CompetenceId
		{
			get { return keyCompetenceId; }
			set { IsChanged |= (keyCompetenceId != value); keyCompetenceId = value; }
		}
			
		
		/// <summary>
		/// RoleId:角色Id
		/// </summary>		
		public virtual int RoleId
		{
			get { return keyRoleId; }
			set { IsChanged |= (keyRoleId != value); keyRoleId = value; }
		}
			
		
		/// <summary>
		/// CompetenceName:权限名称
		/// </summary>		
		public virtual string CompetenceName
		{
			get { return keyCompetenceName; }
			set	
			{
				if ( value != null)
					if( value.Length > 50)
						throw new ArgumentOutOfRangeException("CompetenceName:权限名称无效!", value, value.ToString());
				
				IsChanged |= (keyCompetenceName != value); keyCompetenceName = value;
			}
		}
			
		
		/// <summary>
		/// CompetenceCode:权限编码
		/// </summary>		
		public virtual string CompetenceCode
		{
			get { return keyCompetenceCode; }
			set	
			{
				if ( value != null)
					if( value.Length > 50)
						throw new ArgumentOutOfRangeException("CompetenceCode:权限编码无效!", value, value.ToString());
				
				IsChanged |= (keyCompetenceCode != value); keyCompetenceCode = value;
			}
		}
			
		
		/// <summary>
		/// CompetenceDescription:权限描述
		/// </summary>		
		public virtual string CompetenceDescription
		{
			get { return keyCompetenceDescription; }
			set	
			{
				if ( value != null)
					if( value.Length > 50)
						throw new ArgumentOutOfRangeException("CompetenceDescription:权限描述无效!", value, value.ToString());
				
				IsChanged |= (keyCompetenceDescription != value); keyCompetenceDescription = value;
			}
		}
			
		
		/// <summary>
		/// Version:版本号
		/// </summary>		
		public virtual int Version
		{
			get { return keyVersion; }
			set { IsChanged |= (keyVersion != value); keyVersion = value; }
		}
			
			
		/// <summary>
		/// 对象是否为新增
		/// </summary>
		public virtual bool IsAdded
		{
			get { return keyCompetenceId == 0 ? true : false; }
		}
			
		/// <summary>
		/// 对象的值是否被改变
		/// </summary>
		public virtual bool IsChanged
		{
	 		get { return keyIsChanged; }
            set { keyIsChanged = value; }
		}
		
		/// <summary>
		/// 对象是否已经被删除
		/// </summary>
		public virtual bool IsDeleted
		{
			get { return keyIsDeleted; }
		}
		
		#endregion 
		
		#region 公有函数
		
		/// <summary>
		/// 标记对象已删除
		/// </summary>
		public virtual void MarkAsDeleted()
		{
			keyIsDeleted = true;
			keyIsChanged = true;
		}
		
		/// <summary>
		/// 初始化对象标记
		/// </summary>
		public virtual void ResetMark()
		{
			keyIsDeleted = false;
			keyIsChanged = false;
		}
		
		#endregion
		
		#region 重写Equals和HashCode
		/// <summary>
		/// 用唯一值实现Equals
		/// </summary>
		public override bool Equals( object obj )
		{
			if( this == obj ) return true;
			if( ( obj == null ) || ( obj.GetType() != GetType() ) ) return false;
			Competence castObj = (Competence)obj; 
			return ( castObj != null ) &&
				(keyCompetenceId == castObj.CompetenceId );
		}
		
		/// <summary>
		/// 用唯一值实现GetHashCode
		/// </summary>
		public override int GetHashCode()
		{
			int hash = 57; 
			hash = 27 * hash * keyCompetenceId.GetHashCode();
			return hash; 
		}
		#endregion
		
		
	}
}
